
#ifdef LOGGING_EXPORTS
#define LOGGING_API __declspec(dllexport)
#else
#define LOGGING_API __declspec(dllimport)
#endif

#ifndef __LOGGING_H
#define __LOGGING_H

#include <iostream>
#include <sstream>

/*
#define ADD(a,b,c,d,e) AddEntry(a,b,c,d,e,__FILE__,__LINE__,_T("") )
#define ADDEX(a,b,c,d,e,f) AddEntry(a,b,c,d,e,__FILE__,__LINE__,f )
#define GADD(a,b,c,d,e) \
ALogGlobalInit(); \
if(NULL != pgLog) \
{ \
	pgLog->AddEntry(a,b,c,d,e,__FILE__,__LINE__,_T("") ); \
}

#define GADDEX(a,b,c,d,e,f) \
ALogGlobalInit(); \
if(NULL != pgLog) \
{ \
	pgLog->AddEntry(a,b,c,d,e,__FILE__,__LINE__,f ); \
}
*/

enum LogType { eFile = 0, eXml = 1, eDatabase = 2, eOther = 3, eReserved = 9 }; 

class LOGGING_API CEntry 
{
public:
  enum SEVERITY { Info = 0, Debug = 1, Warning = 2, Critical = 3, Error = 4 };

  CEntry();
  CEntry(const char* descr);
  CEntry(SEVERITY sev, const char* descr);
  virtual ~CEntry();  
  std::ostream& operator<<(std::ostream& out);
  const int getId() const;
  const char* getGuid() const;
  const char* getTimestamp() const;
  const int getSeverity() const;
  const char* getDescription() const;
  const char* getStackTrace() const;
  void setStackTrace(const char* text);
protected:
  long m_id;
  char m_guid[128];
  char * m_ts;
  SEVERITY m_severity;
  char * m_desc;
  char * m_stack;
};

LOGGING_API std::ostream& operator<<(std::ostream& out, CEntry::SEVERITY& e);

class LOGGING_API CLogger 
{
public:
  CLogger();
  virtual ~CLogger();
  virtual void write(CEntry * entry) = 0;
  virtual const char* getLogName() const;
protected: 
  int m_SevLevel;
  char* m_szLogname;
};

class LOGGING_API CLoggingFactory 
{
public:    
  CLoggingFactory();
  virtual ~CLoggingFactory();
  virtual CLogger * getLogger() = 0;
  virtual const LogType getLogtype() const;
private:
  char* m_szLogType;
};

#endif

